#include "mines.h"
#include "Minesweeper.h"
#include <QtGui>
#include <math.h>
#include <vector>
#include "SVector2D.h"
#include "CParams.h"
#include "controller.h"

CParams params;

 int main(int argc, char **argv)
 {
     QApplication app(argc, argv);
     qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
     QGraphicsScene scene;
     scene.setSceneRect(0, 0, CParams::iWindowWidth, CParams::iWindowHeight);
     scene.setItemIndexMethod(QGraphicsScene::NoIndex);


     Controller *controller = new Controller(&scene);
     controller->init();
     controller->move(QPoint(-10,-10));
     controller->setFixedWidth(CParams::iWindowWidth+20);
     controller->setFixedHeight(CParams::iWindowHeight+20);
     scene.addWidget(controller);

     QPen pen(Qt::black, 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
     scene.addRect(-10,-10,CParams::iWindowWidth+20,CParams::iWindowHeight+20,pen);

     mines **mines        = controller->getMineArray();
     Minesweeper **mineSweepers = controller->getMineSweeperArray();

     for (int i = 0; i < CParams::iNumSweepers; ++i)
         scene.addItem(mineSweepers[i]);

     for(int i = 0; i < CParams::iNumMines; i++)
         scene.addItem(mines[i]);

     QGraphicsView view(&scene);
     view.setRenderHint(QPainter::Antialiasing);
     view.setCacheMode(QGraphicsView::CacheBackground);
     view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
     view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "MineSweepers"));
     view.setFixedHeight(CParams::iWindowHeight + 75);
     view.setFixedWidth(CParams::iWindowWidth + 75);
     view.show();

     return app.exec();
     app.quit();
 }


